// 二星https://iai.sh.cn/problem/555
#include <bits/stdc++.h>
using namespace std;

int days[12]; // 预存前若干月的总天数

// 判断是否是闰年
bool isLeapYear(int year) {
  return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}

int main() {
  int y, m, d;
  char ch; // 用于接收分隔符
  cin >> y >> ch >> m >> ch >> d;

  // 初始化每个月的天数
  days[0] = 0;
  days[1] = 31;
  days[2] = days[1] + 28;
  days[3] = days[2] + 31;
  days[4] = days[3] + 30;
  days[5] = days[4] + 31;
  days[6] = days[5] + 30;
  days[7] = days[6] + 31;
  days[8] = days[7] + 31;
  days[9] = days[8] + 30;
  days[10] = days[9] + 31;
  days[11] = days[10] + 30;

  int total = days[m - 1] + d;
  if (m > 2 && isLeapYear(y))
    total++;

  cout << total;

  return 0;
}
